﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TimeStart
{
    public partial class Preferences : Form
    {
        bool autocheckout;
        string language, autocheck;
        public Preferences()
        {
            InitializeComponent();
        }

        private void Preferences_Load(object sender, EventArgs e)
        {
            label1.Text = Home.tmex[33];
            cautocheckforupdates.Text = Home.tmex[34];
            capply.Text = Home.tmex[35];
            ccancel.Text = Home.tmex[36];
            TextReader input = new StreamReader("settings.ini");
            autocheck = input.ReadLine();
            language = input.ReadLine();
            input.Close();
            if (autocheck.Contains("0"))
            {
                cautocheckforupdates.Checked = false;
                autocheckout = false;
            }
            else
            {
                cautocheckforupdates.Checked = true;
                autocheckout = true;
            }
            if (language.Contains("eng"))
                clanguage.SelectedIndex = 0;
            else
                clanguage.SelectedIndex = 1;
        }

        private void ccancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void capply_Click(object sender, EventArgs e)
        {
            TextWriter output = new StreamWriter("settings.ini",false);
            if (autocheckout)
                output.WriteLine("upds=" + 1);
            else
                output.WriteLine("upds=" + 0);
            if (clanguage.SelectedIndex == 0)
                output.WriteLine("lang=eng");
            else
                output.WriteLine("lang=ita");
            output.Close();
            this.Close();
            MessageBox.Show(Home.tmex[37]);
        }

        private void cautocheckforupdates_CheckStateChanged(object sender, EventArgs e)
        {
            
            if (cautocheckforupdates.Checked == true)
                autocheckout = true;
            else
                autocheckout = false;
            
        }

       

      
    }
}
